//
//  DefaultVC.m
//  tcpoctest
//
//  Created by gump on 12/14/12.
//  Copyright (c) 2012 gump. All rights reserved.
//

#import "DefaultVC.h"
#import "sendQuitLogin.h"

@interface DefaultVC ()

@end

@implementation DefaultVC

- (id)init
{
    self = [super init];
    if (self) {
        iTimer = 0;
    }
    return self;
}

-(void)initUI
{
    UIImageView *bgimage = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, WINDOW_WIDTH, WINDOW_HIGTH)];
    bgimage.image = [UIImage imageNamed:@"Default.png"];
    
    [self.view addSubview:bgimage];
}

-(void)viewWillHide
{
}

-(void)viewWillShow
{
}

-(void)WarnningNetBreak
{
    if ([DataControl shareControl].blogin) {
        [[netManager sharedNetManager].sendquitl SendQuitLogin];
        [DataControl shareControl].blogin = false;
    }
    
    [[ViewManager sharedViewManager] showView: VI_LOGIN
                            withIsRemoveCurV:true
                                withDirection:VD_RIGHT];
    
    if ([ViewManager sharedViewManager].currentVC != nil) {
        [[ViewManager sharedViewManager] showFailHUDWithStatus:@"当前没有网络耶"
                                                     withDelay:2
                                                      withView:[ViewManager sharedViewManager].currentVC.view];
    }
}

-(void)WarnningServerBreak
{
    if ([DataControl shareControl].blogin) {
        [[netManager sharedNetManager].sendquitl SendQuitLogin];
        [DataControl shareControl].blogin = false;
    }
    
    [[ViewManager sharedViewManager] showView: VI_LOGIN
                             withIsRemoveCurV:true
                                withDirection:VD_RIGHT];
    
    if ([ViewManager sharedViewManager].currentVC != nil) {
        [[ViewManager sharedViewManager] showFailHUDWithStatus:@"网络故障，请检查当前网络"
                                                     withDelay:2
                                                      withView:[ViewManager sharedViewManager].currentVC.view];
    }

}

-(void)NetTimeOut
{
    if ([DataControl shareControl].blogin) {
        [[netManager sharedNetManager].sendquitl SendQuitLogin];
        [DataControl shareControl].blogin = false;
    }
    
    [[ViewManager sharedViewManager] showView: VI_LOGIN
                             withIsRemoveCurV:true
                                withDirection:VD_RIGHT];
}

-(void)UICustomTick
{
    if (iTimer < 100) {
        ++iTimer;
    }
    else
    {
        [self NetTimeOut];
        iTimer = 0;
    }
}

@end
